function I= getpospoint2(matlast,mat2dpoints,x,I,Im)

%error=0;
K=[1573.287920411348068 0 702.964654360824966;0 1587.526419194196706 627.725369611522524;0 0 1];
    for i=1:size(matlast,1) 
        newpixworldi=t3dto3d([matlast(i,1) matlast(i,2) matlast(i,3) 1],(pi*x(1)/180),(pi*x(2)/180),[0.26 0 0]);
       
        %--------------pinhole
      
        Xim2(1,1)=newpixworldi(1,1)/newpixworldi(3,1);
        Xim2(1,2)=newpixworldi(2,1)/newpixworldi(3,1);
        Xim2(1,3)=1;
        
        %----------------pixeles
        
        pixi=K*Xim2';
        pixi=abs(round(pixi));
        I(pixi(2,1),pixi(1,1))=Im(mat2dpoints(i,1),mat2dpoints(i,2));
        %intenI=int32(Im(mat2dpoints(i,1),mat2dpoints(i,2)));
        %intenIs=int32(I(pixi(2,1),pixi(1,1)));
        
        %fprintf('valor original %d  - valor siguiente %d  = %d \n',intenI,intenIs,((intenI-intenIs))/2);
        
        %error = error + ((intenI-intenIs)^2)/2;
    
    end
    %figure, imshow(I);

end